﻿namespace WebPacker.Helpers
{
	using System;

	public static class DateTimeHelper
	{
		private static long unixEpochTicks = new DateTime(1970, 1, 1, 0, 0, 0, 0).Ticks;

		public static long ToTimestamp(this DateTime value)
		{
			return (value.Ticks - unixEpochTicks) / TimeSpan.TicksPerSecond;
		}

		public static DateTime FromTimestamp(long timestamp)
		{
			return new DateTime(unixEpochTicks + (timestamp * TimeSpan.TicksPerSecond));
		}
	}
}
